/**
 * 
 */
package info.pello.struts.tulebox.example;

/**
 * Generates orchis or elvish names
 * @author Raquel Valenzuela Ganuza
 *
 */
public class Name {
	private int syllables;
	private String  language;
	private char[] vocals={'a','e','i','o','u'};
	private char[] consonants= {'b','c','d','f','g','h','j','k','m','l','n','p','q','r','s','t','v','w','x','y','z'};
	private String[] orchis={"ur","og","ag","un"};
	private String [] elvish={"il", "al", "el", "in", "ir"};
	
	/**
	 * Constructor for a new Name
	 * @param number
	 * @param lang
	 */
	public Name(int number, String lang){
		this.syllables= number;
		this.language= lang;
	}
	
	/**
	 * generateName
	 * Generates an orchis or elvish name
	 * @return String
	 */
	public String generateName(){
		String result="";
		
		for (int i=0; i<this.syllables-1;i++){
			result=result+vocals[(int) Math.floor(Math.random()*5)];
			result=result+consonants[(int) Math.floor(Math.random()*21)];
		}
		
		if ("Orchis".equals(this.language)){
			result=result+orchis[(int) Math.floor(Math.random()*4)];
		}else {
			result=result+elvish[(int) Math.floor(Math.random()*5)];
		}
		
		return result;
	}

}
